import React from 'react';
import { NavLink, useRoutes } from 'react-router-dom'
import routes from './routes/index'
import Header from './components/Header';
import './App.css'


const App = () => {

  // 高亮navLink
  function computedClassName ({isActive}) {
    return isActive? 'list-group-item atguigu' : 'list-group-item'
  }

  const element = useRoutes (routes)

  return (
    <div>
      <div className="row">
          <div className="col-xs-offset-2 col-xs-8">
            <Header></Header>
          </div>
        </div>

        <div className="row">
          <div className="col-xs-2 col-xs-offset-2">
            <div className="list-group">

              {/* <a className="list-group-item" href="./about.html">About</a>
              <a className="list-group-item active" href="./home.html">Home</a> */}

              <NavLink to='/home' end className={computedClassName}>Home</NavLink>
              <NavLink to='/about' className={computedClassName}>About</NavLink>

            </div>
          </div>

          <div className="col-xs-6">
            <div className="panel">
              <div className="panel-body">
                {/* 注册路由 */}

                {element}

              </div>
            </div>
          </div>
        </div>
    </div>
  );
}

export default App;


